package com.fz.mapper;

import com.fz.entity.Book;
import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;
import org.springframework.stereotype.Service;

import java.util.Date;
import java.util.List;
import java.util.Map;

/**
 * Created by webrx on 2017-09-12.
 */
@Service("daoo")
//这个地方的daoo找的是BookDAO.java中的private BookMapper daoo;，以建立BookDAO.java和BookMapper.java之间的关系
public interface BookMapper {
    //用注解试试
    @Select("select * from db_book where id=#{id}")
    public Book queryById(int id);

    @Delete("delete from db_book where id=#{id}")
    public int deleteById(int id);

    //public int save1(String name, double price, Date date);
    @Insert("insert into db_book value(null,#{name},#{price},#{bdate})")
    public int save(Book book);

    @Insert("insert into db_book value(null,#{name},#{price},#{bdate})")
    public int save1(@Param("name") String name,@Param("price") double price,@Param("bdate") Date bdate);

    //采用配置的方式
    public List<Map<String ,Object>> query();

    @Select("select * from db_book")
    public List<Book> queryAll();

}
